package com.itheima.mall.controller.omsController;

import com.itheima.mall.service.omsService.OmsOrderSettingService;
import com.itheima.pojo.oms.OmsOrderSetting;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/orderSetting")
public class OmsOrderSettingController {
    @Autowired
    private OmsOrderSettingService omsOrderSettingService;

    /**
     * 获取指定订单设置
     * @param id
     * @return
     */
    @GetMapping("/{id}")
    public ResponseEntity<OmsOrderSetting> findById(@PathVariable Integer id){

        OmsOrderSetting omsOrderSetting =    omsOrderSettingService.findById(id);
        return ResponseEntity.ok(omsOrderSetting);
    }

    /**
     * 修改指定订单设置
     * @param id
     * @param omsOrderSetting
     * @return
     */
    @PostMapping("/update/{id}")
    public ResponseEntity updateSetting(@PathVariable Integer id, @RequestBody OmsOrderSetting omsOrderSetting){

       omsOrderSettingService.updateById(id,omsOrderSetting);
        return ResponseEntity.ok(null);
    }

}